package com.shop.admin.controller;

import com.shop.admin.entity.Organization;
import com.shop.admin.result.ApiResult;
import com.shop.admin.service.OrganizationService;
import com.shop.admin.service.ShopAdminService;
import com.shop.admin.service.ShopIndentService;
import com.shop.admin.utils.PageUtils;
import com.shop.admin.vo.DataAdminVo;
import com.shop.admin.vo.OrganizationAdminCountVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Api(tags = {"OrganizationController"},description = "学校组织接口")
@RestController
@RequestMapping("/api/organization")
public class OrganizationController {

    @Resource
    private OrganizationService organizationService;

    @Resource
    private ShopIndentService indentService;

    @Resource
    private ShopAdminService adminService;

    //学校列表查询
//    @GetMapping("/school/list")
//    @ApiOperation(value = "获取学校列表",notes = "无需传参")
//    public ApiResult list(@RequestParam Map<String, Object> params){
//        PageUtils page = organizationService.schoolList(params);
//        return ApiResult.ok(page);
//    }

//    //获取学校下的组织列表查询
//    @GetMapping("/school/son/list")
//    @ApiOperation(value = "获取学校列表",notes = "无需传参")
//    public ApiResult sonList(@RequestParam Map<String, Object> params){
//        Map<String,List<Organization>> page = organizationService.sonSchoolList(params);
//        return ApiResult.ok(page);
//    }

    //获取学校楼栋管理员列表
    @GetMapping("/school/admin/list")
    @ApiOperation(value = "获取学校楼栋管理员列表",notes = "楼栋id(orgId)")
    public ApiResult schoolAdminList(@RequestParam Map<String, Object> params){
        PageUtils page = adminService.adminSchoolList(params);
        return ApiResult.ok(page);
    }

    //获取学校下的楼栋管理员模块列表查询
    @PostMapping("/school/data/list")
    @ApiOperation(value = "获取学校下次级楼栋管理员模块列表",notes = "传参：学校下楼栋id(orgId)")
    public ApiResult organizationAdmin(@ApiParam("参数:{\n" +
            "    \"orgId\":\"2\",\n" +
            "}")@RequestBody DataAdminVo vo){
        List<OrganizationAdminCountVo> vos = organizationService.getOrganizationAdminCount(vo);
        return ApiResult.ok(vos);
    }
}
